//删除有序数组中的重复项 ||
//https://leetcode.cn/problems/remove-duplicates-from-sorted-array-ii/?envType=study-plan-v2&envId=top-interview-150

class Solution {
public:
    int removeDuplicates(vector<int>& nums) 
    {
        int n = nums.size();
        if(n <= 2) return n;
        int begin = 1;
        int end = 2;
        while(end < n)
        {
            if(nums[end] != nums[begin - 1])
            {
                nums[++begin] = nums[end];
            }
            end++;
        }
        return begin + 1;
    }
};